<template>
  <mu-container class="pos-r">
    <mu-row class="padt10">
      <mu-paper :z-depth="1" style="width: 100%" class="round5 pad5">
        <mu-flex align-items="center">
          <mu-flex>
            <mu-button icon @click="$goback()">
              <mu-icon value="arrow_back"></mu-icon>
            </mu-button>
          </mu-flex>
          <mu-flex fill><h3>产品导入</h3></mu-flex>
          <mu-flex>
            <div class="padr10">
              <mu-button small fab color="red" @click="create()">
                <mu-icon value="save"></mu-icon>
              </mu-button>
            </div>
          </mu-flex>
        </mu-flex>
      </mu-paper>
    </mu-row>
    <mu-row class="padt10 pos-r">
      <mu-paper class="pad10" style="width: 100%" :z-depth="1">
        <div class="pad10">
          <div>
            <!--        表单-->
            <formCreator ref="form" :form.sync="form" :items="items"></formCreator>
            <!--        表单-->
            <mu-row>
              <mu-button color="red" @click="submit()">上传</mu-button>
            </mu-row>
          </div>
        </div>
      </mu-paper>
    </mu-row>
  </mu-container>

</template>

<script>
import api from '@/assets/js/api'
import formCreator from '@/components/FormCreator/Creator/Creator'
import entity from '@/components/FormItem/entity'
import entityViewer from '@/components/FormItem/entityViewer'
import com from '../../../assets/js/com'

export default {
  name: 'ProductImport',
  components: {formCreator, entity, entityViewer},
  data () {
    return {
      id: undefined,
      active: 0,
      text: '',
      form: {},
      items: {},
      questions: [],
      latters: ['A', 'B', 'C', 'D', 'E', 'F', 'G']
    }
  },
  created () {
    let _this = this
    api.get('/admin/ProductTrade/import/form', {}, function (res) {
      console.log(res)
      _this.form = res.d.show.entity
      _this.items = res.d.show.form
    })
  },
  mounted () {
  },
  methods: {
    submit () {
      let text = this.text
      let _this = this
      api.post('/admin/ProductTrade/import', this.form, function (res) {
        console.log(res.d)
        if (res.s*1 === 1) {
          _this.$toast.success('导入成功')
        }
      })
    },
  },
  watch: {}
}
</script>

<style scoped>

</style>
